export default {
  getURLParam (name, url) {
    url = url || location.search
    const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
    const r = url.substr(url.indexOf('?') + 1).match(reg)
    return r != null ? r[2] : null
  },
  getURLParams (url) {
    url = url || location.search // 获取url中"?"符后的字串
    const params = {}
    if (url.indexOf('?') != -1) {
      const strs = url.substr(url.indexOf('?') + 1).split('&')
      for (let i = 0; i < strs.length; i++) {
        params[strs[i].split('=')[0]] = strs[i].split('=')[1]
      }
    }
    return params
  }
}